package cn.tworice.cryption.service.impl;

import cn.tworice.cryption.service.CryptService;
import cn.tworice.cryption.util.DESUtil;

public class DesServiceImpl implements CryptService {

    private final String key;

    public DesServiceImpl(String key) {
        this.key = key;
    }

    @Override
    public String encrypt(String input) {
        try {
            return DESUtil.encrypt(input, key);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public String decrypt(String input) {
        try {
            return DESUtil.decrypt(input, key);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
